import math

"""
数字型
"""
print("---------------- 数字型  -------------")
number = 60
number += 40
number -= 50
number *= 2
number /= 2

# math 模块
print("----- 乘方  ----")

a = 2
b = 3
print(math.pow(a, b))
print(a ** b)

print('---- 天花板数 和 地板数 -----')
print(math.ceil(math.pi))
print(math.floor(math.pi))

print("----- 角度转化  ----")
print(math.radians(180))

print("----- 三角函数  ----")
print(math.sin(30))

"""
bool型
"""
print("---------------- bool型  -------------")
a = True
b = False
# False：表示一种无的状态，以下值都是False
print(bool(''))
print(bool([]))
print(bool({}))
print(bool(()))
print(bool(None))
print(bool(0))

print("-----")
print(True and False)
print(True or False)
print(True and '')
print(False and '')
print('-----')
a = list(range(5))
b = 4
c = (b in a)
print(type(c))  # <class 'bool'>

"""
字符串
"""
print("---------------- 字符串  -------------")
print("张三说: \"我不是法外狂徒\"")
print("格式化工具: {}".format("format"))
print("zhangsan " + "李四")
print("zhangsan " * 3)
string = "how are you?"

# 常用API
print(len(string))
print(string[:10])
print(string[0:12:2])
print(string[-10:])
print(string[::-1])
print(string.capitalize())
print(string.istitle())
print(string.center(20, '%'))
print(string.count('o'))
print(string.endswith("how"))
print(string.startswith("you"))
print(print(string.find("how")))
print(string.index("a"))
print(string.upper())
print(string.isupper())
print(string.lower())
print(string.islower())
print(string.strip())
print(string.swapcase())

"""
列表
"""
print("---------------- 列表  -------------")
list1 = [1, 2, 3]
list2 = list()
list1[0] = 'one'
print(list1)
list1.append('hello')
print(list1)
list1.clear()
list1.copy()

"""
元组
"""
print("---------------- 元组 tuple  -------------")
tuple1 = (1, 2, 3, 4, 5)
print(tuple1.index(2))
print(tuple1.count(2))
a, b = 10, 20
print(a)
print(b)

"""
字典 dict
"""
print("---------------- 字典 dict  -------------")
dict1 = {
    'one': 1,
    'two': 2,
    'three': 3,
    'four': 4,
    "一": 1
}
print(dict1['two'])
# 根据value找key
ones = [key for key, value in dict1.items() if value == 1]
print(ones)

# 将2个列表和成一个列表
list1 = ['星期一', '星期二', '星期三', '星期四', '星期五', '星期六']
list2 = [1, 2, 3, 4, 5]
dict1 = dict(zip(list1, list2))
list3 = list(zip(list1, list2))
print(dict1)
print(list3)

student = ["zhao", "qian", "sun", "li", "wang"]
dict1 = dict.fromkeys(student, 10)
print(dict1)
print(dict1.get("zhang", 10))
print(dict1.keys())
print(dict1.values())
print(dict1.items())
dict1["zhang"] = 20
dict1.setdefault("zhang", 1000)
print(dict1)
dict1.pop("zhang")
print(dict1)

"""
输出:
---------------- 数字型  -------------
----- 乘方  ----
8.0
8
---- 天花板数 和 地板数 -----
4
3
----- 角度转化  ----
3.141592653589793
----- 三角函数  ----
-0.9880316240928618
---------------- bool型  -------------
False
False
False
False
False
False
-----
False
True

False
-----
<class 'bool'>
---------------- 字符串  -------------
张三说: "我不是法外狂徒"
格式化工具: format
zhangsan 李四
zhangsan zhangsan zhangsan 
12
how are yo
hwaeyu
w are you?
?uoy era woh
How are you?
False
%%%%how are you?%%%%
2
False
False
0
None
4
HOW ARE YOU?
False
how are you?
True
how are you?
HOW ARE YOU?
---------------- 列表  -------------
['one', 2, 3]
['one', 2, 3, 'hello']
---------------- 元组 tuple  -------------
1
1
10
20
---------------- 字典 dict  -------------
2
['one', '一']
{'星期一': 1, '星期二': 2, '星期三': 3, '星期四': 4, '星期五': 5}
[('星期一', 1), ('星期二', 2), ('星期三', 3), ('星期四', 4), ('星期五', 5)]
{'zhao': 10, 'qian': 10, 'sun': 10, 'li': 10, 'wang': 10}
10
dict_keys(['zhao', 'qian', 'sun', 'li', 'wang'])
dict_values([10, 10, 10, 10, 10])
dict_items([('zhao', 10), ('qian', 10), ('sun', 10), ('li', 10), ('wang', 10)])
{'zhao': 10, 'qian': 10, 'sun': 10, 'li': 10, 'wang': 10, 'zhang': 20}
{'zhao': 10, 'qian': 10, 'sun': 10, 'li': 10, 'wang': 10}
"""